<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="layui/dist/css/layui.css"/>
	</head>
	<body>
		<form>
			<p>您还可以输入：<span class="charsLeft"></span>字</p>
			<textarea maxlength="140" class="limited" cols="35" rows="10"></textarea>
		</form>

		<script src="layui/dist/layui.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//config的设置是全局的
			layui.config({
				base: 'js/' //假设这是test.js所在的目录
			}).extend({ //设定模块别名
				maxlength: 'extend/jquery.maxlength' 
			});

			//使用
			layui.use('maxlength', function(){
			  	var maxlength = layui.maxlength
			  	$ = layui.jquery;
			  
			  	$('.limited').maxlength({
					'feedback': '.charsLeft'
				});

			});
		</script>
	</body>
</html>
